#ifndef MUSIC_H
#define MUSIC_H

#include <QWidget>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QJsonDocument >
#include <QJsonObject >
#include <QStandardItemModel>
#include <QMessageBox>
#include <QMediaPlayer>
#include <QMediaPlaylist>
#include <QTcpServer>
#include <QJsonArray>
#include <QPainter>

//#include "smarthome.h"

namespace Ui {
class music;
}

class music : public QWidget
{
    Q_OBJECT

public:
    explicit music(QWidget *parent = nullptr);
    ~music();
    void pareJson(QByteArray byteArray);
    void paintEvent(QPaintEvent *event);

public slots:
    void replyFinished(QNetworkReply *reply);
    void parejson(QByteArray byteArray);
    void togglePlayPause();
private slots:
    void on_pushButton_clicked();

    void on_tableView_doubleClicked(const QModelIndex &index);
    void on_horizontalSlider_sliderReleased();

    void positionchanged(qint64 position);
    void durationchanged(qint64 duration);

    void on_pushButton_close_clicked();

    void on_pushButton_prev_clicked();

    void on_pushButton_next_clicked();

    void on_pushButton_begin_clicked();

    void on_pushButton_2_clicked();

    void volumechange(int value);
private:
    Ui::music *ui;
    QNetworkAccessManager *manager;
    QStandardItemModel * pModel;

    QMediaPlaylist *playlist;
    QMediaPlayer * player;

    int id = -1;
    QString songName;
    QString albumName;
    QString singerName;
    float duration = -1;
    int fen;
    int miao;
    QString s;
    bool isPlaying;
    QIcon icon1,icon2,icon3,icon4;
    bool voice;
};

#endif // MUSIC_H
